package vn.fpt.fsoft.dao.impl;

import org.aspectj.lang.annotation.Aspect;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;

import vn.fpt.fsoft.dao.UserDao;
import vn.fpt.fsoft.entities.User;

@Aspect
public class UserDaoImpl implements UserDao {
	@Autowired
	private SessionFactory sessionFactory;
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	@Override
	public boolean checkLogin(User user) {
		Criteria cr = sessionFactory.getCurrentSession().createCriteria(User.class);
		cr.add(Restrictions.eq("account", user.getAccount()));
		cr.add(Restrictions.eq("password",user.getPassword()));
		return cr.list().size() > 0;
	}
	
}
